<?php

namespace App\Http\Admin\Controllers;

use App\Exceptions\InvalidRequestException;
use App\Http\Admin\Services\AuthService;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Validator;


class AuthController extends Controller
{
    protected $authService;
    public function __construct(AuthService $authService)
    {
        $this->authService = $authService;
    }

    public function index()
    {
        return view('admin.login.index');
    }

    public function token(Request $request)
    {
        $attributes = $request->all();

        $result = $this->authService->token($attributes);

        return res('token',$result);
    }

    public function initUser(Request $request){
        $token = $request->input('token',null);

        $user_info = $this->authService->initUser($token);

        return res('认证信息',$user_info);
    }

}
